class Solution {
    public:
        int minSwaps(string s) {
            int cnt = 0,ans = 0;
            for(char c : s){
                if(c == '['){
                    cnt++;
                }else{
                    cnt--;
                }
                if(cnt == -1){
                    ans++,cnt = 1;
                }
            }
            return ans;
        }
    };